package servlet;

import hbase.HbaseUtil;
import hbase.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * @author Lu Ruotong
 * @date 2022/3/19 17:25
 */
@WebServlet("/studentQuery6")
public class studentQuery6 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String semester = req.getParameter("semester");

        HbaseUtil hbaseUtil = new HbaseUtil();

        List<Student> display = hbaseUtil.semesterQuery(semester);


        resp.setContentType("text/html;charset=utf-8");
        PrintWriter pw = resp.getWriter();


        for (int i = 0; i < display.size(); i++) {
            pw.write(display.get(i).getName() + "  ");
            pw.write(display.get(i).getDate_ruxue() + "  ");
            pw.write(display.get(i).getTelephone() + "  ");
            pw.write(display.get(i).getSemester() + "  ");
            pw.write(display.get(i).getStudentStatus() + "  ");
        }


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}

